const express = require('express')
const router = express.Router()

const path = require("path");
const multer = require("multer")
var storage = multer.diskStorage({
    // 配置文件上传后存储的路径
    destination: function (req, file, cb) {
        cb(null, path.resolve('./head_img'))
    },
    // 配置文件上传后存储的路径和文件名
    filename: function (req, file, cb) {
        console.log('file', file);
        cb(null, Date.now() + path.extname(file.originalname))
    }
})
console.log(path.resolve('./head_img'));
var upload = multer({
    storage: storage
})
// 导入用户路由处理函数模块
const userHandler = require('../router_handler/userinfo')

//获取当前用户信息
router.get('/current', userHandler.current)
//修改用户头像
router.post('/editAva', upload.single("file"), userHandler.editAva)

// //根据id添加信息
// router.post('/addtest',userHandler.addtest)

module.exports = router